package io.renren.modules.generator.controller;

import java.util.List;
import java.util.Map;

import io.renren.modules.generator.entity.SpringLambEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.generator.entity.冬羔体重预测Entity;
import io.renren.modules.generator.service.冬羔体重预测Service;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;




/**
 * 冬羔体重预测
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-05-01 21:59:01
 */
@RestController
@RequestMapping("冬羔体重预测")
public class 冬羔体重预测Controller {
	@Autowired
	private 冬羔体重预测Service 冬羔体重预测Service;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("冬羔体重预测:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<冬羔体重预测Entity> 冬羔体重预测List = 冬羔体重预测Service.queryList(query);
		int total = 冬羔体重预测Service.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(冬羔体重预测List, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("冬羔体重预测:info")
	public R info(@PathVariable("id") Long id){
		冬羔体重预测Entity 冬羔体重预测 = 冬羔体重预测Service.queryObject(id);
		
		return R.ok().put("冬羔体重预测", 冬羔体重预测);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("冬羔体重预测:save")
	public R save(@RequestBody 冬羔体重预测Entity 冬羔体重预测){
		冬羔体重预测Service.save(冬羔体重预测);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("冬羔体重预测:update")
	public R update(@RequestBody 冬羔体重预测Entity 冬羔体重预测){
		冬羔体重预测Service.update(冬羔体重预测);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("冬羔体重预测:delete")
	public R delete(@RequestBody Long[] ids){
		冬羔体重预测Service.deleteBatch(ids);
		
		return R.ok();
	}

	@RequestMapping("/timelist")
	@RequiresPermissions("springlamb:list")
	public R timelist(@RequestParam Map<String, Object> params){
		//查询列表数据
		Query query = new Query(params);
		System.out.println("冬羔体重预测Entity得到的参数"+params+"/n下一个参数"+query);
		List<冬羔体重预测Entity> animalpriceList = 冬羔体重预测Service.timeList(query);
		int total = 冬羔体重预测Service.timeTotal(query);

		PageUtils pageUtil = new PageUtils(animalpriceList, total, query.getLimit(), query.getPage());

		return R.ok().put("page", pageUtil);
	}
	
}
